import axios from 'axios'
import router from './../router'
import { Message } from "element-ui"


class Interface{
    
    user=[];
    login (params) {
        axios
          .post('/login/',params)
          .then(res => {
            if (res.status === 200 & res.data.code === 1) {
              this.user=res.data.username
              sessionStorage.setItem('accessToken',res.session)
              Message({
                message: "登录成功",
                type: "success",
              });
              router.replace({path: '/homePage'})
            }else{
              Message({
                message: res.data.msg,
                type: "error",
              });
            }
          })
          .catch(failResponse => {
            Message({
              message: "调用异常",
              type: "error",
            });
          })
      }

    interfaceTest(){
        this.$axios
        .get('/test_interface/')
        .then((res)=>{
            if(res.data["success"]==='true'){
                this.$message({
                    message: '执行完成',
                    type: 'success'
                  })
            }
        })
    }
    //路由跳转
    testHtml(path,id) {
        router.push({
          path:path,
          query:{
            id:id
          }
        
        }) 
    }



}
export default new Interface();
